import './index.scss'
import { Progress, Button } from 'antd'
import { useState, useEffect } from 'react'
import { useNavigate } from 'react-router'
// const num=0
const App = () => {
    const [num, setNum] = useState(0)
    const navigate = useNavigate()
    useEffect(() => {
        function addNum() {
            setInterval(() => {
                setNum((prevPercent) => {
                    const newPercent = prevPercent + 5;
                    if (newPercent > 100) {
                        return 100;
                    }
                    return newPercent;
                });
            }, 100)
        }
        addNum()
    }, [])
    return (
        <div className="upgradation">
            {/* <div></div> */}
            {/* <div className='upgradation_header'>—</div> */}
            <h1>腾讯课堂老师端</h1>
            {
                num === 100 ? (<Button type="primary" onClick={() => {
                    navigate('/login')
                }}>重新登陆</Button>) : ''
            }
            <div className='upgradation_footer'>
                {
                    num === 100 ? (<div>已经下载完毕.</div>) : (<div>腾讯课堂学生端正在下载升级文件,请稍等...</div>)
                }
                <Progress percent={num} />
            </div>
        </div>
    )
}
export default App